import {
	storeList,
	storeTypeList,
	operateRecord
} from '@/common/api_store.js'
export default {
	data() {
		return {
			loading: true,
			hasMore: true, // 是否有更多数据
			listData: [],
			queryParams: {
				queryValue: '',
				longitude: '',
				latitude: '',
				storeType: '',
				pageNum: 1,
				pageSize: 5
			},
		}
	},

	onReachBottom() {
		console.log('到底了')
		if (this.hasMore) {
			this.getList()
		}
	},
	methods: {
		async getList() {
			const postData = await storeList(this.queryParams)
			if (postData.data.length) {
				this.listData = this.listData.concat(postData.data)
				this.queryParams.pageNum += 1
				this.loading = false
			} else {
				this.hasMore = false
				this.loading = false
			}
		},
		// 打电话
		async handleCall(item) {
			// 用户操作记录
			await operateRecord({ id: item.id, type: 2 })
			uni.makePhoneCall({
				phoneNumber: item.storePhone
			})
			
		},
		// 导航
		async callouttap(item) {
			// 用户操作记录
			await operateRecord({ id: item.id, type: 1 })
			uni.openLocation({
				latitude: Number(item.latitude),
				longitude: Number(item.longitude),
				name: item.title,
				address: item.storeAddr
			})
		}
	}
}